import { Component, createRef } from 'react'; 
import Hooks1 from '../components/Hooks1.jsx';
import Hooks2 from '../components/Hooks2.jsx';
import Layout1 from '../layouts/Layout1.js';

export default class HooksTest1 extends Component {
	constructor (props) {
		super(props);
		this.hooks2ref = createRef();
	}
	// 总数据
	state = {
		// 新增-弹窗开头
		mag: 'h111'
	}
	//被子级调用 1
	test1 () {
		console.log('parent', 11);
	}
	//调用子级 2
	test2 () {
		console.log('parent', 22);
		this.hooks2ref.current.getInfo();
	}
	// 渲染函数
    render() {
    	return (
			<Layout1>
				<button onClick={() => this.test1()}>按钮1</button>
				<button onClick={() => this.test2()}>按钮2:调用子级方法</button>
				<Hooks1 name1='11' name2='22'></Hooks1>
				<Hooks2 ref={this.hooks2ref} add1={this.test1}></Hooks2>
			</Layout1>
		);
    }
};
